<template>
  <div class="container">
     <div class="header_img">
        <img src="../../../../static/images/notices.png" />
    </div>
    <dv-scroll-board :config="config" style="width:100%;height:100%" @click="noticeItemTap"/>

   <noticeDetail ref="notices"></noticeDetail>
  </div>
</template>

<script>
// import untils from '@/untils/index.js'
import noticeDetail from './notice_detail'
export default {
  components: {noticeDetail},
  name: 'Notices',
  data () {
    return {
      config: {
        header: ['标题', '时间'],
        data: [],
        headerHeight: 34,
        headerBGC: '#0D1B6D',
        oddRowBGC: '#02063a',
        evenRowBGC: '#030842',
        rowNum: 15,
        waitTime: 2000,
        align: ['left']
      },
      pageIndex: 1,
      pageSize: 100,
      list: []

    }
  },
  watch: {

  },
  created () {
    this.init()
    // 定时半小时拉取
    setInterval(() => {
      this.init()
    }, 1800000)
  },
  methods: {
    async init () {
      var that = this
      let data = {
        pageIndex: this.pageIndex,
        pageSize: this.pageSize,
        sortFields: 'createTime_d',
        queryList: []
      }

      let result = await this.$api.getNoticeList(data)
      if (result.code === 200) {
        that.list = result.data.records
        let tmp = []
        that.list.map((val, index) => {
          tmp.push([val.name, val.createTime])
        })
        that.config = {
          header: ['标题', '时间'],
          data: tmp,
          headerHeight: 34,
          headerBGC: '#0D1B6D',
          oddRowBGC: '#02063a',
          evenRowBGC: '#030842',
          rowNum: 15,
          waitTime: 2000,
          align: ['left']
        }
      }
    },
    noticeItemTap (row) {
      // console.log(row)
      // console.log(this.list[row.rowIndex])
      this.$refs.notices.show(this.list[row.rowIndex])
    }
  }
}
</script>

<style>
.container {
  height: 100%;
  overflow: hidden;
}
.header_img{
  width: 100%;
  /* height: 45px; */
  text-align: center;
}

</style>
